// v2_jwt/main.go
package main

import (
	"fmt"
	"log"

	"grpc-jwt-yonghurenzheng/v2.2_jwt/config"
	"grpc-jwt-yonghurenzheng/v2.2_jwt/handlers" // 注意路径

	"github.com/gin-gonic/gin"
)

func main() {
	config.InitDB()
	r:= gin.Default()
	jwt_public:=r.Group("/v2/jwt")
	{
		jwt_public.POST("/register",handlers.Register)
		jwt_public.POST("/login",handlers.Login)
	}
	jwt_private:=r.Group("/v2/jwt")
	jwt_private.Use(handlers.JWTMiddleware())
	{
		jwt_private.GET("/profile",handlers.Profile)
		jwt_private.DELETE("/delete_user",handlers.DeleteUser)
	}
	port := "8080"
	fmt.Printf("🚀 Gin 服务启动于 http://localhost:%s\n", port)
	if err := r.Run(":" + port); err != nil {
		log.Fatal(err)
	}

}